<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>定位</title>
    <style>
      /* 定位：脱离标准流 */
      .father {
        width: 400px;
        height: 400px;
        background-color: red;
        /* 相对定位 */
        position: relative;
      }

      .one {
        width: 100px;
        height: 100px;
        background-color: pink;
        /* 绝对定位 */
        position: absolute;
        /* left: 20px; */
        /* top: 20px; */
        left: 50%;
        top: 50%;
        /* 过渡 */
        transform: translate(-50%, -50%);
        /* 层级 */
        z-index: 1;
      }

      .two {
        width: 100px;
        height: 100px;
        background-color: green;
        /* 绝对定位 */
        position: absolute;
        left: 40px;
        top: 40px;
      }
    </style>
  </head>
  <body>
    <div class="father">
      <div class="one">one</div>
      <div class="two">two</div>
    </div>
  </body>
</html>
